import type { PropType } from "vue";
import type { IconClass } from "../../types";
import { defineComponent, inject } from "vue";
import { $t } from "@/plugins/i18n";
import { SYMBOL_FETCH_DATA } from "../../types";

interface Props {
    iconClass: IconClass;
}

export default defineComponent((props: Props) => {
    const fetchData = inject(SYMBOL_FETCH_DATA)!;

    return () => (
        <span
            class={`icon-[ri--refresh-line] ${props.iconClass}`}
            v-tippy={{ content: $t("button.reload") }}
            onClick={fetchData}
        />
    );
}, {
    name: "ReloadTable",
    props: {
        iconClass: {
            type: String as PropType<IconClass>,
            required: true,
        },
    },
});
